import android.graphics.Rect
import androidx.compose.runtime.mutableStateOf

abstract class BaseSpriteModel(open val drawInfo: DrawInfo,
                               open var onClick:OnMahjongClickListener? = null)

data class MahjongModel(val type:MahjongType, val number:Int, override val drawInfo: DrawInfo,
                        override var onClick:OnMahjongClickListener? = null): BaseSpriteModel(drawInfo, onClick) {
    val isSelected = mutableStateOf(false)
}

data class DrawInfo(val srcRect: Rect, var dstRect: Rect? = null)

enum class MahjongType(val typeValue: String) {
    WAN("wan"),
    TONG("tong"),
    TIAO("tiao"),
    FENG("feng"),
    SANYUAN("sanyuan");

    companion object {
        fun fromTypeValue(typeValue: String): MahjongType {
            return when (typeValue) {
                "wan" -> WAN
                "tong" -> TONG
                "tiao" -> TIAO
                "feng" -> FENG
                "sanyuan" -> SANYUAN
                else -> WAN
            }
        }
    }
}

interface OnMahjongClickListener {
    fun onClick(mahjongModel: MahjongModel)
}

